using System;
using System.Collections;

namespace nHydrate.Generator.Common.GeneratorFramework
{
	public abstract class BaseModelCollection : BaseModelObject, ICollection, IEnumerable
	{
		public BaseModelCollection(INHydrateModelObject root)
			: base(root)
		{
		}

		#region Methods

		public virtual Array Find(string key)
		{
			try
			{
				var retval = new ArrayList();
				foreach (INHydrateModelObject element in this)
				{
					if (string.Compare(element.Key, key, true) == 0)
						retval.Add(element);
				}
				return retval.ToArray();
			}
			catch (Exception ex)
			{
				throw;
			}
		}

		public abstract void Clear();
		public abstract void AddRange(ICollection list);

		#endregion

		#region IEnumerable Members

		public abstract IEnumerator GetEnumerator();

		#endregion

		#region ICollection Members

		public abstract int Count { get;}
		public abstract void CopyTo(Array array, int index);
		public abstract object SyncRoot { get;}
		public abstract bool IsSynchronized { get;}

		#endregion

	}
}
